﻿using BasicInformation.ApiWrite.Application.Command.Depot;
using BasicInformation.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BasicInformation.ApiWrite.Controllers
{
    /// <summary>
    /// 仓库管理控制器——写
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class DepotController : ControllerBase
    {
        private readonly IMediator mediator;

        public DepotController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 添加仓库管理接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> AddDepot(AddDepotCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 删除仓库管理接口
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<int>> DelDepot([FromQuery]DelDepotCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改仓库管理接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> UpdateDepot(UpdateDepotCommand request)
        {
            return mediator.Send(request);
        }
    }
}
